package metalink.admin;

import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;

import model.admin.GetBatchListMo;
import model.admin.GetCourseListMo;
import model.admin.GetListsMo;
import model.admin.ModifyBatchDetailsMo;
import model.admin.ModifyStudentsMo;

import vo.BatchDetailsVo;
import vo.StudentDetailsVo;
import vo.mixed.CourseListVo;

import com.opensymphony.xwork2.ActionSupport;

public class ModifyBatchList extends ActionSupport {
	ArrayList<BatchDetailsVo> batch_list;
	BatchDetailsVo new_batch;
	int batch_id;
	String batch_name;
	String start_date;
	String end_date;
	String degree_selected;
	int student_count;
	int start_year;
	int incharge_id;
	String incharge_start_date;
	String incharge_end_date;
	String incharge_selected;
	ArrayList<String> course_list;
	ArrayList<String> degree_list;
	ArrayList<String> incharge_list;
	ArrayList<String> student_list;

	public String getIncharge_selected() {
		return incharge_selected;
	}

	public void setIncharge_selected(String incharge_selected) {
		this.incharge_selected = incharge_selected;
	}

	public ArrayList<String> getIncharge_list() {
		return incharge_list;
	}

	public void setIncharge_list(ArrayList<String> incharge_list) {
		this.incharge_list = incharge_list;
	}

	public ArrayList<String> getDegree_list() {
		return degree_list;
	}

	public void setDegree_list(ArrayList<String> degree_list) {
		this.degree_list = degree_list;
	}

	public ArrayList<String> getCourse_list() {
		return course_list;
	}

	public void setCourse_list(ArrayList<String> course_list) {
		this.course_list = course_list;
	}

	public ArrayList<BatchDetailsVo> getBatch_list() {
		return batch_list;
	}

	public void setBatch_list(ArrayList<BatchDetailsVo> batch_list) {
		this.batch_list = batch_list;
	}

	public String getIncharge_start_date() {
		return incharge_start_date;
	}

	public void setIncharge_start_date(String incharge_start_date) {
		this.incharge_start_date = incharge_start_date;
	}

	public String getIncharge_end_date() {
		return incharge_end_date;
	}

	public void setIncharge_end_date(String incharge_end_date) {
		this.incharge_end_date = incharge_end_date;
	}

	String description;
	private int student_id;
	private String student_name;
	private String city;
	private String address_line_1;
	private String email_id;
	private String state;
	private String mobile_number;

	public BatchDetailsVo getNew_batch() {
		return new_batch;
	}

	public void setNew_batch(BatchDetailsVo new_batch) {
		this.new_batch = new_batch;
	}

	public int getBatch_id() {
		return batch_id;
	}

	public void setBatch_id(int batch_id) {
		this.batch_id = batch_id;
	}

	public String getBatch_name() {
		return batch_name;
	}

	public void setBatch_name(String batch_name) {
		this.batch_name = batch_name;
	}

	public String getStart_date() {
		return start_date;
	}

	public void setStart_date(String start_date) {
		this.start_date = start_date;
	}

	public String getEnd_date() {
		return end_date;
	}

	public void setEnd_date(String end_date) {
		this.end_date = end_date;
	}

	public int getStudent_count() {
		return student_count;
	}

	public void setStudent_count(int student_count) {
		this.student_count = student_count;
	}

	public int getStudent_id() {
		return student_id;
	}

	public void setStudent_id(int student_id) {
		this.student_id = student_id;
	}

	public String getStudent_name() {
		return student_name;
	}

	public void setStudent_name(String student_name) {
		this.student_name = student_name;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getAddress_line_1() {
		return address_line_1;
	}

	public ArrayList<String> getStudent_list() {
		return student_list;
	}

	public void setStudent_list(ArrayList<String> student_list) {
		this.student_list = student_list;
	}

	public void setAddress_line_1(String address_line_1) {
		this.address_line_1 = address_line_1;
	}

	public String getEmail_id() {
		return email_id;
	}

	public void setEmail_id(String email_id) {
		this.email_id = email_id;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getMobile_number() {
		return mobile_number;
	}

	public void setMobile_number(String mobile_number) {
		this.mobile_number = mobile_number;
	}

	public int getStart_year() {
		return start_year;
	}

	public void setStart_year(int start_year) {
		this.start_year = start_year;
	}

	public int getIncharge_id() {
		return incharge_id;
	}

	public void setIncharge_id(int incharge_id) {
		this.incharge_id = incharge_id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDegree_selected() {
		return degree_selected;
	}

	public void setDegree_selected(String degree_selected) {
		this.degree_selected = degree_selected;
	}

	public String execute() throws Exception {
		GetListsMo list = new GetListsMo();
		setDegree_list(list.getDegreeList());
		setIncharge_list(list.getInchangeList());
		setStudent_list(list.getStudentList());

		return SUCCESS;
	}

	public String editBatch() throws Exception {
		GetBatchListMo BatchListObject = new GetBatchListMo();
		setBatch_list(BatchListObject.getBatchList());

		BatchDetailsVo newBatch = new BatchDetailsVo();
		newBatch.setBatch_id(getBatch_id());
		newBatch.setBatch_name(getBatch_name());
		newBatch.setDescription(getDescription());
		newBatch.setIncharge_name(incharge_selected);
		newBatch.setEnd_date(getEnd_date());
		newBatch.setStart_date(getStart_date());
		newBatch.setStart_year(getStart_year());
		newBatch.setDegree_name(degree_selected);
		newBatch.setStudent_count(getStudent_count());
		ModifyBatchDetailsMo new_object = new ModifyBatchDetailsMo();
		int result = new_object.editBatchDetails(newBatch);
		if (result == 1)
			return SUCCESS;
		else {
			return ERROR;
		}

	}

	public String submitNewBatch() throws Exception {
		GetBatchListMo BatchListObject = new GetBatchListMo();
		setBatch_list(BatchListObject.getBatchList());

		BatchDetailsVo newBatch = new BatchDetailsVo();
		newBatch.setBatch_name(getBatch_name());
		newBatch.setDescription(getDescription());
		newBatch.setIncharge_name(incharge_selected);
		newBatch.setDegree_name(degree_selected);
		newBatch.setEnd_date(getEnd_date());
		newBatch.setIncharge_end_date(incharge_end_date);
		newBatch.setIncharge_start_date(incharge_start_date);
		newBatch.setStart_date(getStart_date());
		newBatch.setStart_year(getStart_year());
		newBatch.setStudent_count(getStudent_count());

		ModifyBatchDetailsMo new_object = new ModifyBatchDetailsMo();
		System.out.println(degree_selected + "  degree selected ");
		int res = new_object.addBatchDetails(newBatch, degree_selected);
		if (res == 1) {
			System.out.println("success\n");
			return SUCCESS;
		} else {
			System.out.println("error\n");
			return ERROR;
		}
	}

	public String deleteBatchDetails() throws Exception {
		ModifyBatchDetailsMo deleteObj = new ModifyBatchDetailsMo();
		if (deleteObj.deleteBatchDetails(batch_id) == 1) {
			System.out.println("\t correct update " + batch_id + "\n");
			return SUCCESS;
		} else
			return ERROR;
	}

	public String addNewBatchCourse() {

		GetListsMo listCourses = new GetListsMo();
		setCourse_list(listCourses.getCourseList(batch_id, 0, 0));

		return SUCCESS;
	}

	public String addNewBatchStudent() {
		
		ModifyStudentsMo mo = new ModifyStudentsMo();
		StudentDetailsVo StudentDetails = new StudentDetailsVo();
		StudentDetails.setStudent_id(student_id);
		StudentDetails.setStudent_name(student_name);
		StudentDetails.setCity(city);
		StudentDetails.setAddress_line_1(address_line_1);
		StudentDetails.setEmail_id(email_id);
		StudentDetails.setState(state);
		StudentDetails.setMobile_number(mobile_number);
		mo.addBatchStudentDetails(StudentDetails, batch_id);
		return SUCCESS;

	}

}
